{extend name="layout:base" /}

{block name="style"}
    <link rel="stylesheet" href="__STATIC__/kindeditor/themes/default/default.css"/>
    <script charset="utf-8" src="__STATIC__/kindeditor/kindeditor-min.js"></script>
    <script charset="utf-8" src="__STATIC__/kindeditor/lang/zh-CN.js"></script>
{/block}

{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form">
                <div class="layui-row layui-form-item">
                    <label class="layui-form-label">用户名：</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" value="" lay-verify="required"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-row layui-form-item">
                    <label class="layui-form-label">所属客服：</label>
                    <div class="layui-input-block">
                        <select name="kf_id" >
                            {volist name="kf_list" id="vo"}
                            <option value="{$vo.id}" >{$vo.username}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-row layui-form-item">
                    <label class="layui-form-label">公司名称：</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" value=""   autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-row layui-form-item">
                    <label class="layui-form-label">手机：</label>
                    <div class="layui-input-block">
                        <input type="text" name="mobile" value="" maxlength="11" lay-verify="phone"  autocomplete="off" class="layui-input">
                    </div>
                </div>


                <div class="layui-row layui-form-item">
                    <label class="layui-form-label">银行卡：</label>
                    <div class="layui-input-block">
                        <input type="text" name="card" value="" lay-verify="required"  autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-row layui-form-item">
                    <label class="layui-form-label">备注：</label>
                    <div class="layui-input-block">
                        <textarea type="text" name="remarks" autocomplete="off" class="layui-textarea"></textarea>
                    </div>
                </div>

                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button class="layui-btn" lay-submit="" lay-filter="btnAdd">保存</button>
                            <a class="layui-btn layui-btn-primary" href="javascript:parent.location.reload();">返回</a>
                        </div>
                    </div>
                </div>

            </form>
        </div>
    </div>
</div>
{/block}


{block name="script"}
<script>
    layui.config({
        base: '__STATIC__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: '/lib/index' //主入口模块
    }).use(['index', 'table', 'jquery', 'layer', 'form', 'element', 'upload','laydate'], function () {
        var $ = layui.$,
            layer=layui.layer,
            form = layui.form,laydate = layui.laydate;

        form.on('submit(btnAdd)', function (data) {
            console.log(data.field);

            $.post("{:url('add')}", data.field, function (result) {
                if (result['code'] == 0) {
                    layer.msg(result['msg'], {icon: 6, time: 1000}, function () {
                        parent.location.reload();

                        window.parent.location.reload();//刷新父页面
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);
                    });
                } else {
                    layer.msg(result['msg'], {icon: 3, time: 3000});
                }
            });
            return false;

        });
    });

    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('textarea[name="content"]', {
            allowFileManager: true
        });
        K('#btnImgUpload').click(function () {
            editor.loadPlugin('image', function () {
                editor.plugin.imageDialog({
                    imageUrl: K('#imageurl').val(),
                    clickFn: function (url, title, width, height, border, align) {
                        K('#imageurl').val(url);
                        editor.hideDialog();
                        K('#imageView').html('');
                        K('#imageView').append('<img src="' + url + '" height="50">');
                    }
                });
            });
        });
        K('#btnImgUpload2').click(function () {
            editor.loadPlugin('image', function () {
                editor.plugin.imageDialog({
                    imageUrl: K('#imageurl2').val(),
                    clickFn: function (url, title, width, height, border, align) {
                        K('#imageurl2').val(url);
                        editor.hideDialog();
                        K('#imageView2').html('');
                        K('#imageView2').append('<img src="' + url + '" height="50">');
                    }
                });
            });
        });
    });
</script>
{/block}